package com.example.leetcode.leetcode;

import java.util.*;

/**
 * @author zhuhaitao
 * @email zhuhaitao@imoran.net
 * @date 2020/7/29 6:41 下午
 * <p>
 *
 * 2 3 4 5
 * 3 5,2 4
 * 5,3,4,2

 *
 * <p>
 * <p>
 * 2 3 4 5 6 7
 * 3 5 7, 2 4 6
 * 5,3 7,
 */
public class Test2 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String line = scanner.nextLine();
        String[] strings = line.split(" ");
        List<Person> current = new ArrayList<>();
        for (int i = 0; i < strings.length; i++) {
            String string = strings[i];
            Person person = new Person();
            person.setId(i);
            person.setLevel(Integer.parseInt(string));
            current.add(person);
        }
        List<List<Person>> result = getWinAndLose(current);
        List<Person> win = result.get(0);
        List<Person> lose = result.get(1);


        scanner.close();
    }

    private static List<List<Person>> getWinAndLose(List<Person> current){
        List<Person> win = new ArrayList<>();
        List<Person> lose = new ArrayList<>();
        for (int i = 0; i < current.size(); i = i + 2) {
            Person left = current.get(i);
            Person right = current.get(i + 1);
            if (left.getLevel() == right.getLevel()) {
                if (left.getId() <= right.getId()) {
                    win.add(left);
                    lose.add(right);
                } else {
                    win.add(right);
                    lose.add(left);
                }
            } else {
                if (left.getLevel() < right.getLevel()) {
                    win.add(right);
                    lose.add(left);
                } else {
                    win.add(left);
                    lose.add(right);
                }
            }
        }
        List<List<Person>> result = new ArrayList<>();
        result.add(win);
        result.add(lose);
        return result;
    }

    static class Person {
        private int id;
        private int level;

        public int getId() {
            return id;
        }

        public void setId(int id) {
            this.id = id;
        }

        public int getLevel() {
            return level;
        }

        public void setLevel(int level) {
            this.level = level;
        }
    }
}